package com.ms;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * 关于泛型的继承；
 * ArrayList<Object> 继承了 List<Object>
 * ArrayList<String> 并没有继承 List<Object>
 *
 *  ? 等价于 ? extends Object
 *
 *
 * @author carter
 * create time    2018-08-20
 */
public class TestFanxin {


    public void method1(List<Object> list)
    {

    }


    public void method2()
    {
//        this.method1(new ArrayList<Object>());
//        this.method1(new ArrayList<String>());
        this.method1(new LinkedList<Object>());
    }

    public void method3(List<? extends Object> list)
    {

    }

    public void method4(){}
    {
        method3(new ArrayList<Object>());
        method3(new ArrayList<String>());
        method3(new LinkedList<Integer>());

    }

    public void method5(List<?> list)
    {

    }

    public void method6(){}
    {
        method5(new ArrayList<Object>());
        method5(new ArrayList<String>());
        method5(new LinkedList<Integer>());

    }


}
